﻿var studentButton;
var musicButton;
var adButton;
var accountTypeTitle;
var accountType;

var classYear;
var musicGroup;
var adGroup;

$(document).ready(function() {
    $("#members li").livequery('click', function() {
        var $item = $(this).find(".memberDesc");
        $.blockUI({ message: $item, css: {
            padding: '1em', cursor: 'hand', textAlign: 'left', border: 'none', background: '#1d5875 url("../../Content/Images/Studio/showBack.png") 0px 0px repeat-x'
        }
        });
        $(".blockOverlay").attr('title', 'Click to return.').click($.unblockUI);
        $(".blockMsg").attr('title', 'Click to return.').click($.unblockUI);
    });


    accountType = $("#memberType");
    accountTypeTitle = $("#accountType");

    studentButton = $("#createStudent");
    studentButton.click(function() { setAccountType("Student"); });
    musicButton = $("#createMusicGroup");
    musicButton.click(function() { setAccountType("MusicGroup"); });
    adButton = $("#createAdvertiser");
    adButton.click(function() { setAccountType("Advertiser"); });

    classYear = $("#classYearGroup");
    musicGroup = $("#musicGroup");
    adGroup = $("#adGroup");

    setStudent();

});



function setAccountType(type) {
    switch (type) {
        case "Student":
            setAccountCheck(studentButton);
            setStudent();
            accountTypeTitle.text("New Student");
            break;
        case "MusicGroup":
            setAccountCheck(musicButton);
            setMusic();
            accountTypeTitle.text("New Music Group");
            break;
        case "Advertiser":
            setAccountCheck(adButton);
            setAdvertiser();
            accountTypeTitle.text("New Advertiser");
            break;
        default:
            setAccountCheck(studentButton);
            break;
    }
}

function setAccountCheck(account) {
    studentButton.removeAttr("checked");
    musicButton.removeAttr("checked");
    adButton.removeAttr("checked");

    account.attr("checked", "checked");
}

function setStudent() {
    hideAllAdditional();
    classYear.slideDown(400, null);
    accountType.val("STUDENT");
}

function setMusic() {
    hideAllAdditional();
    musicGroup.slideDown(400, null);
    accountType.val("MUSICGROUP");
}

function setAdvertiser() {
    hideAllAdditional();
    adGroup.slideDown(400, null);
    accountType.val("ADVERTISER");
}

function hideAllAdditional() {
    classYear.slideUp(400, null);
    musicGroup.slideUp(400, null);
    adGroup.slideUp(400, null);
}